import java.util.concurrent.*;

public class ThreadDemo12 {
    public static void main(String[] args) throws InterruptedException {
        //阻塞队列
        BlockingQueue<String>  queue=new LinkedBlockingQueue<>();
        //1.put入队列
        queue.put("hello1");
        queue.put("hello2");
        queue.put("hello3");
        queue.put("hello4");
        queue.put("hello5");

        //take出队列
        String result1 =queue.take();
        System.out.println(result1);
        String result2 =queue.take();
        System.out.println(result2);
        String result3 =queue.take();
        System.out.println(result3);
        String result4 =queue.take();
        System.out.println(result4);
        String result5 =queue.take();
        System.out.println(result5);
        //队列此时为空,会出现阻塞队列
        String result6 =queue.take();
        System.out.println(result6);

     }
}
